window.addEventListener("load", function (eve){
    window.applicationCache.addEventListener("updateready", function (ev) {
        var appCache = window.applicationCache;
        console.log(appCache);
        //if (appCache === undefined) return;
        if (appCache.status === window.applicationCache.UPDATEREADY){
            if (confirm("A new version of this site is available, load it now?")){
                appCache.swapCache();
                window.location.reload();
            }
        }
    }, false);
    setTimeout("updateLineStatus()", 1000);
}, false);

var updateLineStatus = function () {
    var line_status = document.getElementById("line-status");
    if (navigator.onLine){
        line_status.style.backgroundColor = "green";
        line_status.innerHTML = "online";
        window.applicationCache.update();
    }else{
        line_status.style.backgroundColor = "red";
        line_status.innerHTML = "offline";
    }
};
